package com.zb_study.method.Exercise;

public class ThreadMethodExercise {
    public static void main(String[] args) throws InterruptedException {

        T3 t3 = new T3();
        Thread thread = new Thread(t3);
        for (int i = 1; i <= 10; i++) {
            Thread.sleep(1000);
            System.out.println("hi "+i);
            if(i == 5) {
                thread.start();
                thread.join();
            }

        }
    }
}


class T3 implements Runnable {

    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            System.out.println("hello " + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}